<template>
  <div class="app-container">
    <el-table :data="adjustList">
      <el-table-column
        label="调价自增主键id"
        v-if="false"
        align="left"
        prop="adjustPriceId"
      />
      <el-table-column label="油品名称" align="left" prop="oilName" />
      <el-table-column label="调整价格" align="left" prop="oilAdjustPrice" />
      <!--
      <el-table-column
        label="生效状态"
        align="left"
        prop="takeEffectStatus"
        :formatter="statusFormat"
      />
      -->
      <el-table-column label="生效状态" align="left" prop="deviceStatus">
        <template slot-scope="scope">
          {{ scope.row.takeEffectStatus == "1" ? "立即生效" : "定时生效" }}
        </template>
      </el-table-column>

      <el-table-column
        label="生效时间"
        align="left"
        prop="takeEffectDate"
        width="180"
      />
      <el-table-column
        label="调价时间"
        align="left"
        prop="adjustDate"
        width="180"
      />
      <el-table-column
        label="油站id"
        v-if="false"
        align="left"
        prop="stationId"
      />
      <el-table-column label="油站名称" align="left" prop="stationName" />
      <el-table-column label="操作员" align="left" prop="operator" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listAdjust } from "@/api/station/adjust";
import { stationinfo } from "@/api/station/gun";

export default {
  name: "Adjust",
  props: ["getListChange"],
  data() {
    return {
      // 总条数
      total: 0,
      // 油品调价信息表格数据
      adjustList: [],
      takeEffectStatusOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        oilName: null,
        oilAdjustPrice: null,
        takeEffectStatus: null,
        takeEffectDate: null,
        adjustDate: null,
        stationId: null,
        stationName: null,
        operator: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  watch: {
    getListChange(newVal, oldVal) {
      this.getList();
    },
  },
  created() {
    this.getList();
    this.getDicts("take_effect_status").then((response) => {
      this.takeEffectStatusOptions = response.data;
    });
  },
  methods: {
    /** 查询油品调价信息列表 */
    getList() {
      this.queryParams.stationId = this.deptId;
      listAdjust(this.queryParams).then((response) => {
        this.adjustList = response.rows;
        this.total = response.total;
      });
    },
    // 菜单状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(
        this.takeEffectStatusOptions,
        row.takeEffectStatus
      );
    },
  },
};
</script>
